package day20171230;

import java.io.*;
import java.util.HashMap;
import java.util.Map;
import java.util.regex.Matcher;
import java.util.regex.Pattern;

public class Student {

    public static void main(String[] args) {

        Map<String,Integer> map=new HashMap<>();
        try {
            BufferedReader reader=new BufferedReader(
                    new FileReader("F:\\names.txt"));
            String sno=null;
            while ((sno=reader.readLine())!=null){

                map.put(sno,0);
            }
            File file=new File("F:\\作业");
            File[] files=file.listFiles();

            //遍历文件夹下每个文件
            for (File f:files){

                String fileName=f.getName();

                Matcher matcher = Pattern.compile("信本1班(\\d+)+(.*)")
                        .matcher(fileName);


                while (matcher.find()) {

                    for (Map.Entry<String,Integer> m:map.entrySet()){

                        String sno1=matcher.group(1);

                        if (sno1.equals(m.getKey())){

                            map.put(sno1,map.get(sno1)+1);
                        }

                    }

                }
            }
            for (Map.Entry<String,Integer> n:map.entrySet()){

                if (n.getValue()==0){

                    System.out.println(n.getKey()+"   "+n.getValue());
                }

            }

        } catch (FileNotFoundException e) {
            e.printStackTrace();
        } catch (IOException e) {
            e.printStackTrace();
        }finally {

        }

    }
}
